<%@ Page Language="VB" MasterPageFile="~/MasterPageExpandable.master" AutoEventWireup="false" CodeFile="ExpenditureEntry.aspx.vb" Inherits="BudgetOnlineEntry_ExpenditureEntry" title="Online Expenditure Entry" %>
 <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
 <%@ Register Src="~/AJAX/PopupMessage.ascx" TagName="PopupMessage" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language="javascript" type="text/javascript">
    function toggleCatDiv(categoryId)
    {
      var divListHidden = GetHiddenObj();
       var divListHiddenValue = divListHidden.value;
        
      var divId='Cat' + categoryId;
      var hrefId='href' + categoryId;
      
      var divObj=document.getElementById(divId);
      var hrefObj=document.getElementById(hrefId);
      
      if (divObj.style.display=='none')
       {
           divObj.style.display='block';
           hrefObj.innerText='-';
           divListHiddenValue=divListHiddenValue +',' + divId; 
       }
      else
        {
           divObj.style.display='none';
           hrefObj.innerText='+';
           divListHiddenValue=divListHiddenValue.replace(divId,'');
           divListHiddenValue=divListHiddenValue.replace(',,',',');
        }

    divListHidden.value=divListHiddenValue;

    }
    
    function GetHiddenObj()
    {
         for (i=0;i<document.forms[0].elements.length;i++)
               if (document.forms[0].elements[i].type=='hidden'  && 
                   document.forms[0].elements[i].id.indexOf('divList')>0)
                     return document.forms[0].elements[i];
    }
    
    function OpenDivList()
    {

        var divList=GetHiddenObj();
        var divListValue =divList.value;

        var divList = divListValue.split(',');
        
        for (i=0;i<divList.length;i++)
        {
          var selectDiv= document.getElementById(divList[i]);
          if (selectDiv!=null)
          {
             selectDiv.style.display='block';
             hrefId=selectDiv.id.replace('Cat','href');
             document.getElementById(hrefId).innerText='-';
          }
        }
    
    }
    
    //function toggleSpendingPlanOption(radioListId)
   // {
   //    if (document.getElementById(radioListId).options[0].selected)
   // }
    
    function ExcelIF(cond,val1,val2)
    {
       if (cond)
          return EvaluateValue(val1);
       else
           return EvaluateValue(val2);
    }
    
    function CancelChanges()
    {
        if (confirm('Are you sure you want to cancel your changes?  Any changes since your last save will be discarded.'))
            self.close();
        else
            return false;
    }
    
    function EvaluateValue(val)
    {
       if (isNaN(val))
           return 0;
       else
           {
            var roundTwo=Math.round(100*val)/100;            
            return parseFloat(roundTwo);
            
           }
    }
    
    
    function EvaluateValueIfDateEntered(catTotalId, dateOfServiceId)
    {
        var dateOfServiceValue=document.getElementById(dateOfServiceId).value;
        var catTotalValue=document.getElementById(catTotalId).value;
        
        if (dateOfServiceValue=='')
            return 0;
        else
            return EvaluateValue(catTotalValue);
    }
    
 
 
    
    function MoneyValue(val)
    {
         var currValue=EvaluateValue(val);
           var roundTwo=Math.round(100*currValue)/100;
            var roundOne=Math.round(10*currValue)/10;
            var roundZero=Math.round(currValue);
            
           // alert(val);
            
            if (roundZero==roundTwo)
                    return roundTwo + '.00';
            
            if (roundOne==roundTwo)
                     return roundTwo + '0';
                     
            return roundTwo;
    }
    
    
    
    function ROUND(val, digits)
    {
          var currValue=EvaluateValue(val);
           var roundTwo=Math.round(100*currValue)/100;
            var roundOne=Math.round(10*currValue)/10;
            var roundZero=Math.round(currValue);
            
            if (digits==0)
                  return roundZero;
                  
            if (digits==1)
                  return roundOne;
            else
                  return roundTwo;      
    }
    
    
</script>

<asp:Literal ID="javascriptLiteral" runat="server"></asp:Literal>
<h1><asp:Label ID="TitleLabel" runat="server"></asp:Label></h1>
<div id="pageDiv2" runat="server" style="height:550px; overflow:auto;">
<asp:UpdatePanel Id="TopUpdatePanel" runat="server">
<ContentTemplate>
<table border="0" style="width:750px;" align="center">
                        <tr>
                          <td style="text-align:right; width:300px;"><asp:Label ID="SpendingPlanLabel" runat="server" Text="Select Spending Plan:" Font-Names="Arial,MS Sans Serif,Verdana,Sans-Serif" Font-Size="smaller"></asp:Label></td><td><asp:DropDownList ID="SpendingPlanDropDownList" runat="server" AutoPostBack="true"></asp:DropDownList></td></tr>
                        
                       <tr id="selectionRow2" runat="server"><td style="text-align:right;"><asp:Label ID="DateRangeLabel" runat="server" Text="Date Range:" Font-Names="Arial,MS Sans Serif,Verdana,Sans-Serif" Font-Size="smaller"></asp:Label></td>
                            <td><asp:TextBox ID="StartDateTextBox" runat="server"></asp:TextBox>&nbsp;to&nbsp;<asp:TextBox ID="EndDateTextBox" runat="server"></asp:TextBox></td></tr>
                       
                        </table>
                        <cc1:CalendarExtender ID="StartDateExtender" TargetControlID="StartDateTextBox" runat="server"></cc1:CalendarExtender>
                        <cc1:CalendarExtender ID="EndDateExtender" TargetControlID="EndDateTextBox" runat="server"></cc1:CalendarExtender>
  </ContentTemplate>
  </asp:UpdatePanel>                     
  <table border="0" style="width:750px;" align="center">
  <tr id="selectionRow3" runat="server">
    <td colspan="2" align="center">
          <asp:Button ID="GetPaymentsButton" runat="server" Text="Show Payments" />
    </td></tr></table>
    <div id="resultsDiv" runat="server" class="accordionContent" style="overflow:auto;">
            <asp:DataList ID="CategoryDataList" runat="server" >
   <ItemTemplate>
               <table style="width:850px;" ><tr><td style="font-family:Arial,MS Sans Serif,Verdana,Sans-Serif;font-size: x-large;font-weight:bold; width:10px;">
                <a id='href<%#Eval("BudgetCategoryId") %>' href=javascript:toggleCatDiv('<%#Eval("BudgetCategoryId") %>')>+</a>
                </td><td style="width:420px;">
               <asp:Label ID="CategoryNameLabel" runat="server" Text='<%#Eval("DisplayName") %>' ToolTip='<%#Eval("BudgetCategoryId") %>' Font-Bold="true" Font-Names="Arial,MS Sans Serif,Verdana,Sans-Serif" Font-Size="Small" CssClass="fontBold"></asp:Label></td>
               <td align="right" style="width:420px;">Total:  $<asp:TextBox ID="CategoryTotalTextBox" runat="server" Enabled="true"  BorderStyle="None" Columns="5" BackColor="Transparent" ForeColor="black" Font-Names="Arial,MS Sans Serif,Verdana,Sans-Serif" Font-Size="Smaller"></asp:TextBox></td>
               </tr>
                      <tr><td style="width:10px;"></td>
                      <td colspan="2">  <div id='Cat<%#Eval("BudgetCategoryId") %>' style="display:none; background-color: Transparent; border:1px solid; font-family:Arial,MS Sans Serif,Verdana,Sans-Serif; font-size:smaller; font-weight:normal;">
                          
                                <table cellpadding="0" cellspacing="0">
                                <asp:Repeater ID="CategoryRowsRepeater" OnItemDataBound="CategoryRowsRepeater_ItemDataBound"  OnDataBinding="CategoryRowsRepeater_DataBinding" runat="server">
                                <ItemTemplate>
                                        <tr><td>
                                               <asp:Label ID="RowNumberLabel" runat="server" Text='<% #Eval("RowNumberDisplay")%>' ToolTip='<%#Eval("DateModified") %>'></asp:Label>
                                               </td>
                                               <asp:Repeater ID="RowItemsRepeater" runat="server" OnItemDataBound="RowItemsRepeater_ItemDataBound" OnDataBinding="RowItemsRepeater_DataBinding">
                                               <ItemTemplate>
                                                 <td align="center"> <table cellpadding="0" cellspacing="0"><tr><td align="center"><asp:Label ID="ItemLabel" runat="server" Text="" Font-Size="X-Small" ToolTip='<%#Eval("BudgetCategoryHeaderId")%>'></asp:Label></td>
                                                                                                 <td align="center"><asp:TextBox ID="ItemTextBox" runat="server" Text='<%#Eval("ItemValue")%>' ToolTip='<%#Eval("ExpenditureReportItemId")%>'> </asp:TextBox></td></tr></table>
                                                         </td>
                                               </ItemTemplate>
                                              </asp:Repeater>
                                        </tr>
                                        
                                </ItemTemplate>
                                <FooterTemplate>
                                    <tr>
                                        <td colspan="4">
                                         <asp:Label ID="AddLabel" runat="server" Text="Add Row: "></asp:Label>
                      <asp:DropDownList ID="AddRowDropDownList" runat="server">
                        <asp:ListItem Text="Blank"></asp:ListItem>
                        <asp:ListItem Text="Virginia"></asp:ListItem>
                        <asp:ListItem Text="Steve"></asp:ListItem>
                        <asp:ListItem Text="Showman"></asp:ListItem>
                      </asp:DropDownList><asp:Button ID="AddRowButton" runat="server" Text="Add" OnClick="AddRowButton_Click" />
                                        </td></tr>  
                                </FooterTemplate>
                              </asp:Repeater>
                              
                              </table>
                              </div></td></tr>
                      </table>
                     
   </ItemTemplate>
   </asp:DataList>
    </div>
    <asp:Panel ID="TotalsPanel" Visible="false" runat="server">
   <table width="825px" border="0"><tr><td width="400px"></td><td align="right" style="width:300px;">Total Payments this Period:</td><td style="width:100px; text-align:right;">$<asp:TextBox ID="SpendingPlanTotalTextBox" runat="server" BorderStyle="None" Columns="6" Style="text-align:right;" BackColor="Transparent"></asp:TextBox></td></tr>
                        <tr><td></td><td align="right">Total Budgeted Amount:</td><td style="text-align:right;">$<asp:TextBox ID="BudgetAmountTextBox" runat="server" BorderStyle="None" Columns="6" Style="text-align:right;" BackColor="Transparent"></asp:TextBox></td></tr>
                        <tr><td align="center"><asp:Button ID="SaveButton" runat="server" Text="Save" /></td>
                        <td colspan="2" ><asp:Button ID="CancelButton" runat="server" Text="Close" /></td></tr>                        
   </table>
   </asp:Panel>
   <asp:Literal ID="CloseWindowLiteral" runat="server"><a href="javascript:self.close()">Close Window</a></asp:Literal>
   <input type=hidden id="divList" runat="server" value="" />
</div>

<uc1:PopupMessage ID="PopupMessage1" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>

